package jjn.carl.binary_tree;

import commons.TreeNode;

/**
 * @author Jjn
 * @since 2023/8/1 17:10
 */
public class LeetCode538 {
    private int sum = 0;
    
    public TreeNode convertBST(TreeNode root) {
        if (root != null) {
            convertBST(root.right);
            sum += root.val;
            root.val = sum;
            convertBST(root.left);
        }
        return root;
    }
}
